package com.sgx.learning.luban.thread;

import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class ThreadPoolTest {
    public static void main(String[] args) {
        ThreadPoolExecutor poolExecutor = new ThreadPoolExecutor(
                1,
                2,
                1L,
                TimeUnit.MINUTES,
                new LinkedBlockingDeque<>(1000));
        for(int i = 0;i<10;i++) {
            int finalI = i;
            poolExecutor.execute(() -> {
                System.out.println(finalI);
                try {
                    Thread.sleep(1000000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            });
        }
    }
}
